//
//  main.cpp
//  Practice9
//
//  Created by 赵世杰 on 2020/7/5.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#include <iostream>
#include "NameSP.hpp"

#include "golf.hpp"

using namespace std;

using namespace SALES;


const int ArSize = 10;

void strcount(const char *str);

struct chaff
{
    char dross[20];
    int slag;
    
};

const int BUF = 512;
char buffer[BUF];


int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    
    
    /*
    golf go ;
    
    
    char *name = "zhaoshijie";
    
    setgolf(go, name, 20);
    
    setgolf(go);
    
    handicap(go, 32);
    
    showgolf(go);
     */
    
    
    /*
    string str ;
    
    getline(cin, str);
    
    while (str != "" || str == "q") {
        
        strcount(str.c_str());
        

        getline(cin, str);
        
        
    }
     */
    
    
    
    /*
    chaff *cf0 = new (buffer) chaff;
    
    stpcpy(cf0->dross, "zhaoshijie");
    
    cf0->slag = 0;
    
    
    chaff *cf1 = new chaff;
    
    stpcpy(cf1->dross, "xiaoshijie");
    
    cf1->slag = 1;
    
    
    chaff list[2] = {*cf0,*cf1};
    
    for (int i=0; i<2; i++) {
        
        chaff cf = list[i];
        
        cout << "dross: " << cf.dross << " slag: " << cf.slag << endl;
        
    }
    */
    
    

    Sales sa;
    
    double ar[] = {100,200,300,400};
    
    setSales(sa, ar, sizeof(ar)/sizeof(ar[0]));
    
    showSales(sa);
    
    setSales(sa);
    
    showSales(sa);
    
    
    return 0;
}



void strcount(const char *str)
{
    static int total = 0;
    
    int count = 0;
    
    cout << "\"" << str << "\" contains ";
    
    while (*str++) {
        
        count++;
        
    }
    
    total+= count;
    
    cout << count << " characters\n";
    cout << total << " characters total\n";
    
}
